GitHub Integration Guide
Overview
NudgeBee's GitHub integration enables automated code analysis and pull request creation for Kubernetes rightsizing recommendations. By annotating your Kubernetes deployments with repository information, NudgeBee can automatically apply resource optimizations directly to your infrastructure code.
What NudgeBee Can Do
- Automated PR Creation: Create pull requests for rightsizing recommendations
- Direct Code Updates: Apply CPU, memory, and replica optimizations to Helm values files
- Traceability: Link recommendations to specific commits and deployments
- Cost Optimization: Automatically implement resource savings in your infrastructure code
Prerequisites
- GitHub Access: Personal account or GitHub App with repository access
- NudgeBee Account: Active account with Kubernetes monitoring enabled
- Kubernetes Deployments: Using Helm charts with standard values files
- Repository Permissions: Read/write access to your infrastructure repositories
Two Types of Annotations
NudgeBee uses two different annotation prefixes for different purposes:
1. workloads.nudgebee.com/ - Source Code Detection
Purpose: Links your running workloads to application source code for event investigation and code analysis.
When to use: When you want NudgeBee to analyze your application code during error investigations.
annotations:
workloads.nudgebee.com/git.repo: "https://github.com/your-org/app-source.git"
workloads.nudgebee.com/git.hash: "abc123def456"
2. ci.nudgebee.com/ - Infrastructure Code (Required for GitHub Adapter)
Purpose: Required for NudgeBee to automatically apply rightsizing recommendations to your Helm values files.
When to use: When you want NudgeBee to create PRs for resource optimizations.
annotations:
ci.nudgebee.com/git.repo: "https://github.com/your-org/k8s-manifests.git"
ci.nudgebee.com/helm.values.filePath: "values-prod.yaml"
Quick Start: Enable Automated Rightsizing PRs
Step 1: Configure GitHub Integration
In NudgeBee UI:
- Navigate to Integrations → GitHub
- Click Add Integration
- Choose authentication method:
Option A: Personal Access Token
- Generate a token at: GitHub → Settings → Developer settings → Personal access tokens
- Required scopes:
repo,workflow - Copy token and paste into NudgeBee
Option B: GitHub App (Recommended)
- Click "Install GitHub App"
- Authorize access to your repositories
- NudgeBee will automatically manage tokens
Step 2: Add Required Annotations
Add these annotations to your Kubernetes Deployment, StatefulSet, or DaemonSet:
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-application
annotations:
# Required: Infrastructure repository URL
ci.nudgebee.com/git.repo: "https://github.com/your-org/k8s-manifests.git"
# Required: Path to your Helm values file
ci.nudgebee.com/helm.values.filePath: "values-prod.yaml"
# Optional: Target branch (defaults to "main")
ci.nudgebee.com/git.branch: "main"
spec:
replicas: 3
template:
spec:
containers:
- name: app
image: myapp:v1.2.3
resources:
requests:
cpu: 500m
memory: 500Mi
Step 3: Apply and Wait
kubectl apply -f deployment.yaml
NudgeBee will:
- Monitor your workload's resource usage
- Generate rightsizing recommendations after collecting enough data
- Automatically create pull requests when optimization opportunities are found
Complete Example
Scenario: Production Deployment with Helm
Repository Structure:
k8s-manifests/
├── charts/
│ └── my-app/
│ ├── Chart.yaml
│ ├── values-dev.yaml
│ ├── values-prod.yaml
│ └── templates/
│ └── deployment.yaml
Deployment with Annotations:
apiVersion: apps/v1
kind: Deployment
metadata:
name: api-server
namespace: production
annotations:
# GitHub adapter annotations (for automated PRs)
ci.nudgebee.com/git.repo: "https://github.com/mycompany/k8s-manifests.git"
ci.nudgebee.com/git.branch: "main"
ci.nudgebee.com/helm.values.filePath: "charts/my-app/values-prod.yaml"
ci.nudgebee.com/git.hash: "f02775982a8b1c3d4e5f6a7b8c9d0e1f2a3b4c5d"
# Optional: Source code annotations (for code analysis)
workloads.nudgebee.com/git.repo: "https://github.com/mycompany/api-server.git"
workloads.nudgebee.com/git.hash: "abc123def456789012345678901234567890abcd"
spec:
replicas: 3
selector:
matchLabels:
app: api-server
template:
metadata:
labels:
app: api-server
spec:
containers:
- name: api
image: registry.example.com/api-server:v2.4.1
resources:
requests:
cpu: 500m
memory: 1Gi
limits:
cpu: 1000m
memory: 2Gi
Your Helm Values File (values-prod.yaml):
replicaCount: 3
image:
repository: registry.example.com/api-server
tag: v2.4.1
resources:
requests:
cpu: 500m
memory: 1Gi
limits:
cpu: 1000m
memory: 2Gi
NudgeBee Will Create a PR Like This:
## Summary
- Rightsized CPU request from 500m to 150m based on 99th percentile usage
- Adjusted Memory request from 1Gi to 600Mi based on observed stability
## Changes Table
| Container | Resource | Before | After | Change |
|-----------|----------|--------|-------|--------|
| api | CPU Request | 500m | 150m | -350m |
| api | CPU Limit | 1000m | 300m | -700m |
| api | Memory Request | 1Gi | 600Mi | -424Mi |
| api | Memory Limit | 2Gi | 800Mi | -1224Mi |
## Motivation
Cost optimization via lower CPU request and reduced memory allocation based on
14 days of production usage data. Potential monthly savings: $147.
📊 [View Full Recommendation](https://app.nudgebee.com/kubernetes/details/account-id?id=recommendation-id)
*View detailed resource analysis, usage patterns, and cost savings in NudgeBee*
Required vs Optional Annotations
Minimum Required (for GitHub Adapter)
annotations:
ci.nudgebee.com/git.repo: "https://github.com/org/repo.git"
ci.nudgebee.com/helm.values.filePath: "values-prod.yaml"
Recommended
annotations:
ci.nudgebee.com/git.repo: "https://github.com/org/repo.git"
ci.nudgebee.com/helm.values.filePath: "values-prod.yaml"
ci.nudgebee.com/git.hash: "abc123def456" # Track deployed version
ci.nudgebee.com/git.branch: "main" # Defaults to "main"
Full Set (with Source Code)
annotations:
# Infrastructure code (for PRs)
ci.nudgebee.com/git.repo: "https://github.com/org/k8s-manifests.git"
ci.nudgebee.com/helm.values.filePath: "values-prod.yaml"
ci.nudgebee.com/git.hash: "abc123"
ci.nudgebee.com/git.branch: "main"
# Application source code (for analysis)
workloads.nudgebee.com/git.repo: "https://github.com/org/app-source.git"
workloads.nudgebee.com/git.hash: "def456"
Annotation Reference
GitHub Adapter Annotations (ci.nudgebee.com/)
| Annotation | Required | Default | Description |
|---|---|---|---|
ci.nudgebee.com/git.repo | Yes | - | HTTPS URL to infrastructure repository |
ci.nudgebee.com/helm.values.filePath | Yes | - | Path to Helm values file (relative to repo root) |
ci.nudgebee.com/git.branch | No | main | Target branch for PRs |
ci.nudgebee.com/git.hash | No | - | Git commit SHA of deployed version |
ci.nudgebee.com/helm.values.rootPath | No | - | JSON path prefix for all values (e.g., app.resources) |
Source Code Annotations (workloads.nudgebee.com/)
| Annotation | Required | Description |
|---|---|---|
workloads.nudgebee.com/git.repo | No | Application source code repository |
workloads.nudgebee.com/git.hash | No | Source code commit SHA |
Advanced: Non-Standard Helm Structures
If your values.yaml doesn't follow the standard Kubernetes resource structure, use these optional annotations: